// https://leetcode.cn/problems/rotate-array/description/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    void rotate(vector<int>& nums, int k) {
        int n = k % nums.size();
        if (!n) return;

        vector<int> tmp(nums.size());
        for (int i = 0; i < n; i++) {
            tmp[i] = nums[nums.size() - n + i];
        }
        for (int i = n; i < nums.size(); i++) {
            tmp[i] = nums[i - n];
        }

        for (int i = 0; i < nums.size(); i++) {
            nums[i] = tmp[i];
        }
    }
};